home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / cpp_libs / sos3-2.lha / src / cfe / cfe.y < prev   
Text File  |  1992-01-23  |  19KB  |  829 lines

  1. /* --------------------------------------------------------------------------
  2.  * Copyright 1992 by Forschungszentrum Informatik (FZI)
  3.  *
  4.  * You can use and distribute this software under the terms of the licence
  5.  * you should have received along with this program.
  6.  * If not or if you want additional information, write to
  7.  * Forschungszentrum Informatik, "STONE", Haid-und-Neu-Strasse 10-14,
  8.  * D-7500 Karlsruhe 1, Germany.
  9.  * --------------------------------------------------------------------------
  10.  */
  11. %token name_tok
  12. %token number_tok
  13.  
  14. %token abstract_tok
  15. %token class_tok
  16. %token definite_tok
  17. %token enum_tok
  18. %token extern_tok
  19. %token friend_tok
  20. %token local_tok
  21. %token operator_tok
  22. %token private_tok
  23. %token protected_tok
  24. %token public_tok
  25. %token schema_tok
  26. %token set_tok
  27. %token static_tok
  28. %token typedef_tok
  29. %token union_tok
  30. %token with_tok
  31.  
  32. %token l_abr_tok
  33. %token r_abr_tok
  34. %token l_br_tok
  35. %token r_br_tok
  36. %token l_brc_tok
  37. %token r_brc_tok
  38. %token l_par_tok
  39. %token r_par_tok
  40.  
  41. %token ampersand_tok
  42. %token ampersand_assign_tok
  43. %token and_tok
  44. %token assign_tok
  45. %token bar_tok
  46. %token bar_assign_tok
  47. %token circumflex_tok
  48. %token circumflex_assign_tok
  49. %token colon_tok
  50. %token comma_tok
  51. %token equal_tok
  52. %token exclam_tok
  53. %token greater_equal_tok
  54. %token less_equal_tok
  55. %token minus_tok
  56. %token minus_assign_tok
  57. %token not_equal_tok
  58. %token or_tok
  59. %token percent_tok
  60. %token percent_assign_tok
  61. %token plus_tok
  62. %token plus_assign_tok
  63. %token rshift_assign_tok
  64. %token lshift_assign_tok
  65. %token slash_tok
  66. %token slash_assign_tok
  67. %token star_tok
  68. %token star_assign_tok
  69. %token semicolon_tok
  70.  
  71. %type <imp>    imports
  72. %type <imp>    import_names
  73. %type <s>    name_tok
  74. %type <s>    name_tok_or_keyword
  75. %type <str>    name
  76. %type <str>    name1
  77. %type <str_l>    names
  78. %type <etd>    enumeration_declaration
  79. %type <ctd>    class_declaration
  80. %type <tn_l>    super_classes
  81. %type <utd>    union_declaration
  82. %type <ttd>    typedef_declaration
  83. %type <xtd>    extern_declaration
  84. %type <i>    extern_size
  85. %type <gp_l>    gen_params
  86. %type <gp_l>    gen_params_1
  87. %type <gp>    gen_param
  88. %type <tn_l>    type_names_with_params
  89. %type <tn>    type_name_with_params
  90. %type <mk>    method_kind_spec
  91. %type <md>    function_method
  92. %type <str>    function_name
  93. %type <str>    operator
  94. %type <str>    operator_string
  95. %type <par_l>    opt_parameters
  96. %type <par_l>    parameters
  97. %type <par_l>    parameters_1
  98. %type <par>    parameter
  99. %type <exp>    default_expr
  100. %type <tn>    type_name
  101. %type <tn>    type_name1
  102. %type <tn_l>    type_names
  103. %type <exp>    expr
  104. %type <exp_l>    exprs
  105. %type <exp_l>    exprs1
  106. %type <i>    number_tok
  107. %type <ie>    number
  108. %type <id>    identifier
  109. %type <tn>    generic_instantiation
  110. %type <b>       reference
  111.  
  112. %{
  113.  
  114. #include <libc.h>
  115.  
  116. #include "sys.h"
  117. #include "smg.h"
  118. #include "cfe_err.h"
  119. #include "mta_sos.h"
  120. #include "cfe.h"
  121. #include "cfe_yacc.h"
  122.  
  123. typedef union {
  124.       sos_Bool                b;
  125.       sos_Int                i;
  126.       sos_Cstring                s;
  127.           sos_Imports                imp;
  128.           sos_String                str;
  129.           sos_String_List            str_l;
  130.       sos_Schema_type_List             td_l;
  131.           sos_Enum_type                etd;
  132.           sos_Class_type            ctd;
  133.           sos_Gen_param                gp;
  134.           sos_Gen_param_List            gp_l;
  135.           sos_Param                par;
  136.           sos_Param_List            par_l;
  137.       sos_Method_kind            mk;
  138.           sos_Method_List            md_l;
  139.           sos_Method                md;
  140.           sos_Union_type            utd;
  141.           sos_Typedef_type            ttd;
  142.           sos_Extern_type            xtd;
  143.           sos_Type_name                tn;
  144.           sos_Type_name_List            tn_l;
  145.           sos_Expr                exp;
  146.           sos_Int_expr                ie;
  147.           sos_Identifier            id;
  148.           sos_Expr_List                exp_l;
  149.         } YYSTYPE;
  150.  
  151. static sos_Type_name cfe_fct_or_comp_type;
  152. static sos_Class_type cfe_ct;
  153. static sos_Bool cfe_is_full_type;
  154. static sos_Bool cfe_is_operator;
  155. static sos_Bool cfe_method_is_abstract,
  156.         cfe_method_is_definite, 
  157.         cfe_method_is_local, 
  158.         cfe_method_is_static, 
  159.         cfe_method_is_value;
  160. static sos_Method_kind cfe_method_kind, cfe_set_method_kind;
  161. static sos_Int cfe_component_offset;
  162. static sos_Type_name_List cfe_gen_insts;
  163.  
  164.  
  165. #include "cfe_lex.h"
  166.  
  167. %}
  168.  
  169. %%
  170.  
  171. %{
  172.  
  173. #include <malloc.h>
  174.  
  175. %}
  176.  
  177. schema_module
  178.     : {  cfe_cnt = sos_Container::create ();
  179.          cfe_ct = sos_Class_type::make (NO_OBJECT);
  180.          cfe_schema = sos_Schema_module::create (cfe_cnt);
  181.          cfe_gen_insts = sos_Type_name_List::create (TEMP_CONTAINER);
  182.       }
  183.       imports
  184.           schema_tok
  185.           name
  186.       {  cfe_schema.set_imports ($2);
  187.          cfe_schema.set_name ($4);
  188.          cfe_init($4, $2);
  189.           }
  190.           l_brc_tok
  191.           type_declarations
  192.           r_brc_tok
  193.       opt_semicolon
  194.       {  cfe_check_schema ();
  195.          cfe_check_generic_instantiations (cfe_gen_insts);
  196.          cfe_finalize();
  197.       }
  198.     | error
  199.        ;
  200.  
  201. imports : extern_import
  202.       {  $$ = sos_Imports::create (cfe_cnt); }
  203.         | with_tok
  204.       import_names
  205.       opt_semicolon
  206.       extern_import
  207.       {  $$ = $2; }
  208.        ;
  209.  
  210. import_names
  211.       : name1
  212.         {  $$ = sos_Imports::create (cfe_cnt);
  213.        cfe_import_module ($$, $1);
  214.     }
  215.       | import_names
  216.         comma_tok
  217.         name1
  218.     {  $$ = $1;
  219.        cfe_import_module ($$, $3);
  220.     }
  221.      ;
  222.  
  223. extern_import : {  cfe_schema.set_has_external_import (FALSE);  }
  224.           | with_tok
  225.             extern_tok
  226.             semicolon_tok
  227.             {  cfe_schema.set_has_external_import (TRUE);  }
  228.           ;
  229.  
  230. opt_semicolon :
  231.           | semicolon_tok
  232.           ;
  233.  
  234. type_declarations
  235.       :
  236.       | type_declarations
  237.         type_declaration
  238.       | error
  239.      ;
  240.  
  241. type_declaration
  242.     : enumeration_declaration
  243.     | class_declaration
  244.     | union_declaration
  245.     | typedef_declaration
  246.       semicolon_tok
  247.     | extern_declaration
  248.       semicolon_tok
  249.     | typedef_tok generic_instantiation
  250.       semicolon_tok
  251.     ;
  252.  
  253. enumeration_declaration
  254.        : enum_tok
  255.          name
  256.          l_brc_tok
  257.          names
  258.          r_brc_tok
  259.      opt_semicolon
  260.      {  cfe_check_type ($2);
  261.             $$ = sos_Enum_type::create (cfe_cnt);
  262.         $$.set_name($2);
  263.         $$.set_object_size (cfe_enum_size ($4.card()));
  264.         $$.set_literals($4);
  265.  
  266.             cfe_type_tab.insert ($2, $$);
  267.             cfe_types.append ($$);
  268.      }
  269.         ;
  270.  
  271. class_declaration
  272.     : class_tok
  273.           name
  274.       {  cfe_ct = sos_Class_type::create (cfe_cnt);
  275.          cfe_ct.set_name ($2);
  276.          cfe_make_class_type ($2, cfe_ct);
  277.          cfe_type_tab.insert ($2, cfe_ct);
  278.       }
  279.           gen_params
  280.           {  cfe_ct.set_gen_params($4); }
  281.           opt_parameters
  282.           {  cfe_ct.set_create_params($6); }
  283.           super_classes
  284.           {  cfe_ct.set_super_classes($8);
  285.          cfe_set_super_closure (cfe_ct);
  286.       }
  287.           l_brc_tok
  288.       {  cfe_ct.set_friends
  289.         (sos_Type_name_List::create (cfe_cnt, FALSE));
  290.          cfe_init_methods (cfe_ct);
  291.          cfe_component_offset = 0;
  292.       }
  293.           method_declarations
  294.           r_brc_tok
  295.       opt_semicolon
  296.           {  $$ = cfe_ct;
  297.          cfe_set_offsets_and_size (cfe_ct, cfe_component_offset);
  298.          cfe_set_inherited_methods (cfe_ct);
  299.          cfe_complete_methods (cfe_ct);
  300.              $$.set_generated_from
  301.         (sos_Generic_instantiation::make(NO_OBJECT));
  302.          cfe_set_root_name (cfe_ct);
  303.              cfe_types.append ($$);
  304.          cfe_ct = sos_Class_type::make (NO_OBJECT);
  305.       }
  306.         ;
  307.  
  308. gen_params : {  $$ = sos_Gen_param_List::make (NO_OBJECT); }
  309.              | l_abr_tok
  310.                gen_params_1
  311.                r_abr_tok
  312.            {  if (cfe_is_full_type)
  313.                      cfe_error (err_USE, err_CFE_FULL_GENERIC);
  314.           $$ = $2;
  315.            }
  316.             ;
  317.  
  318. gen_params_1 : gen_param
  319.            {  $$ = sos_Gen_param_List::create (cfe_cnt, FALSE);
  320.           $$.append ($1);
  321.            }
  322.          | gen_params_1
  323.            comma_tok
  324.            gen_param
  325.            {  if (cfe_lookup_gen_params ($3.get_name(), $1) != NO_OBJECT)
  326.                      cfe_error (err_USE, err_CFE_AMBIGUOUS_GEN_PARAMS);
  327.                   $1.append ($3);
  328.                   $$ = $1;
  329.            }
  330.         ;
  331.  
  332. gen_param : name
  333.         {  $$ = sos_Gen_param::create (cfe_cnt);
  334.            $$.set_name ($1);
  335.            $$.set_super_class (sos_Type_name::make(NO_OBJECT));
  336.         }
  337.       | name
  338.         colon_tok
  339.         type_name
  340.         {  $$ = sos_Gen_param::create (cfe_cnt);
  341.            $$.set_name ($1);
  342.            $$.set_super_class ($3);
  343.         }
  344.       ;
  345.  
  346. opt_parameters
  347.       : {  $$ = sos_Param_List::make (NO_OBJECT);
  348.     }
  349.       | parameters
  350.      ;
  351.  
  352. super_classes
  353.       : {  $$ = sos_Type_name_List::create (cfe_cnt, FALSE);
  354. #ifdef ATT
  355.        if (cfe_ct.operator!=(cfe_get_object_type()))
  356. #else
  357.        if (cfe_ct != cfe_get_object_type())
  358. #endif
  359.           $$.append (cfe_get_object_type());
  360.     }
  361.       | colon_tok
  362.         type_names_with_params
  363.     {  cfe_check_super_classes (cfe_ct, $2);
  364.            $$ = $2;
  365.         }
  366.      ;
  367.  
  368. type_names_with_params : type_name_with_params
  369.              {  $$ = sos_Type_name_List::create (cfe_cnt, FALSE);
  370.                 $$.append ($1);
  371.              }
  372.                | type_names_with_params
  373.              comma_tok
  374.              type_name_with_params
  375.              {  $1.append ($3);
  376.                 $$ = $1;
  377.              }
  378.                ;
  379.  
  380. type_name_with_params
  381.       : type_name
  382.       | type_name
  383.     l_par_tok
  384.     exprs
  385.     r_par_tok
  386.     {  sos_Type_with_params twp = sos_Type_with_params::create (cfe_cnt);
  387.        twp.set_type_name ($1);
  388.        twp.set_params ($3);
  389.        $$ = twp;
  390.     }
  391.      ;
  392.  
  393. method_declarations
  394.       : {  cfe_method_kind     = sos_PRIVATE;
  395.        cfe_set_method_kind = sos_PRIVATE;
  396.     }
  397.       | method_declarations
  398.     {  cfe_method_is_abstract = FALSE;
  399.        cfe_method_is_definite = FALSE;
  400.        cfe_method_is_local    = FALSE;
  401.        cfe_method_is_static   = FALSE;
  402.        cfe_method_is_value    = FALSE;
  403.     }
  404.     method_declaration
  405.      ;
  406.  
  407. method_declaration
  408.       : fct_or_comp_type function_method
  409.       | fct_or_comp_type comp_methods
  410.       | friend
  411.       | method_kind_spec
  412.     {  cfe_method_kind = $1; }
  413.     set_method_kind_spec
  414.     colon_tok
  415.       | error
  416.       ;
  417.  
  418. fct_or_comp_type : fct_or_comp_kind
  419.            type_name
  420.            { cfe_fct_or_comp_type = $2; }
  421.          ;
  422.  
  423. fct_or_comp_kind
  424.     : abstract_tok
  425.       {  cfe_method_is_abstract = TRUE; }
  426.     | definite_tok
  427.       local_or_value_spec
  428.       {  cfe_method_is_definite = TRUE; }
  429.     | static_tok
  430.       {  cfe_method_is_static = TRUE; }
  431.     | local_or_value_spec
  432.     ;
  433.  
  434. local_or_value_spec 
  435.         :
  436.         | local_tok
  437.           {  cfe_method_is_local = TRUE; }
  438.         | exclam_tok
  439.           {  cfe_method_is_value = TRUE; }
  440.         ;
  441.  
  442. method_kind_spec :
  443.         private_tok
  444.     {  $$ = sos_PRIVATE; }
  445.       | protected_tok
  446.     {  $$ = sos_PROTECTED; }
  447.       | public_tok
  448.     {  $$ = sos_PUBLIC; }
  449.      ;
  450.  
  451. set_method_kind_spec :
  452.     {  cfe_set_method_kind = cfe_method_kind; }
  453.       | comma_tok
  454.     method_kind_spec
  455.     set_tok
  456.     {  cfe_set_method_kind = $2; }
  457.      ;
  458.  
  459. function_method
  460.       : function_name
  461.         parameters
  462.         semicolon_tok
  463.         {  if (cfe_method_is_definite)
  464.               cfe_error(err_WNG, err_CFE_NO_DEFINITE_FUNCS);
  465.            if (cfe_method_is_local)
  466.               cfe_error(err_USE, err_CFE_NO_LOCAL_FUNCS);
  467.            if (cfe_method_is_value)
  468.               cfe_error(err_USE, err_CFE_NO_VALUE_FUNCS);
  469.               
  470.            $$ = sos_Method::create (cfe_cnt);
  471.        $$.set_name ($1);
  472.        $$.set_is_abstract (cfe_method_is_abstract);
  473.        if (cfe_method_is_abstract)
  474.           cfe_ct.set_is_abstract (TRUE);
  475.        $$.set_is_static (cfe_method_is_static);
  476.        $$.set_is_operator (cfe_is_operator);
  477.        $$.set_is_predefined (FALSE);
  478.        $$.set_params ($2);
  479.        $$.set_result_type (cfe_fct_or_comp_type);
  480.        $$.set_kind (cfe_method_kind);
  481.        $$.set_defined_in (cfe_ct);
  482.        $$.set_generated_from (sos_Method::make(NO_OBJECT));
  483.        $$.set_impls (sos_Method_impl_List::make (NO_OBJECT));
  484.        cfe_append_method (cfe_ct, $$);
  485.      }
  486.       ;
  487.  
  488. function_name : name
  489.         {  $$ = $1;
  490.            cfe_is_operator = FALSE;
  491.         }
  492.           | operator
  493.         {  $$ = $1;
  494.            cfe_is_operator = TRUE;
  495.         }
  496.           ;
  497.  
  498. operator : operator_tok
  499.        operator_string
  500.        {  $$ = $2; }
  501.     ;
  502.  
  503. operator_string
  504.      : star_tok
  505.        {  $$ = smg_String ("*").make_String (cfe_cnt); }
  506.          | slash_tok
  507.        {  $$ = smg_String ("/").make_String (cfe_cnt); }
  508.          | percent_tok
  509.        {  $$ = smg_String ("%").make_String (cfe_cnt); }
  510.          | plus_tok
  511.        {  $$ = smg_String ("+").make_String (cfe_cnt); }
  512.          | minus_tok
  513.        {  $$ = smg_String ("-").make_String (cfe_cnt); }
  514.          | r_abr_tok r_abr_tok
  515.        {  $$ = smg_String (">>").make_String (cfe_cnt); }
  516.          | l_abr_tok l_abr_tok
  517.        {  $$ = smg_String ("<<").make_String (cfe_cnt); }
  518.          | r_abr_tok
  519.        {  $$ = smg_String (">").make_String (cfe_cnt); }
  520.          | l_abr_tok
  521.        {  $$ = smg_String ("<").make_String (cfe_cnt); }
  522.          | equal_tok
  523.        {  $$ = smg_String ("==").make_String (cfe_cnt); }
  524.          | not_equal_tok
  525.        {  $$ = smg_String ("!=").make_String (cfe_cnt); }
  526.          | less_equal_tok
  527.        {  $$ = smg_String ("<=").make_String (cfe_cnt); }
  528.          | greater_equal_tok
  529.        {  $$ = smg_String (">=").make_String (cfe_cnt); }
  530.          | ampersand_tok
  531.        {  $$ = smg_String ("&").make_String (cfe_cnt); }
  532.          | circumflex_tok
  533.        {  $$ = smg_String ("^").make_String (cfe_cnt); }
  534.          | bar_tok
  535.        {  $$ = smg_String ("|").make_String (cfe_cnt); }
  536.          | and_tok
  537.        {  $$ = smg_String ("&&").make_String (cfe_cnt); }
  538.          | or_tok
  539.        {  $$ = smg_String ("||").make_String (cfe_cnt); }
  540.          | assign_tok
  541.        {  $$ = smg_String ("=").make_String (cfe_cnt); }
  542.          | plus_assign_tok
  543.        {  $$ = smg_String ("+=").make_String (cfe_cnt); }
  544.          | minus_assign_tok
  545.        {  $$ = smg_String ("-=").make_String (cfe_cnt); }
  546.          | star_assign_tok
  547.        {  $$ = smg_String ("*=").make_String (cfe_cnt); }
  548.          | slash_assign_tok
  549.        {  $$ = smg_String ("/=").make_String (cfe_cnt); }
  550.          | percent_assign_tok
  551.        {  $$ = smg_String ("%=").make_String (cfe_cnt); }
  552.          | circumflex_assign_tok
  553.        {  $$ = smg_String ("^=").make_String (cfe_cnt); }
  554.          | ampersand_assign_tok
  555.        {  $$ = smg_String ("&=").make_String (cfe_cnt); }
  556.          | bar_assign_tok
  557.        {  $$ = smg_String ("|=").make_String (cfe_cnt); }
  558.          | rshift_assign_tok
  559.        {  $$ = smg_String (">>=").make_String (cfe_cnt); }
  560.          | lshift_assign_tok
  561.        {  $$ = smg_String ("<<=").make_String (cfe_cnt); }
  562.          | l_par_tok r_par_tok
  563.        {  $$ = smg_String ("()").make_String (cfe_cnt); }
  564.          | l_br_tok r_br_tok
  565.        {  $$ = smg_String ("[]").make_String (cfe_cnt); }
  566.         ;
  567.  
  568. parameters
  569.       : l_par_tok
  570.     r_par_tok
  571.     {  $$ = sos_Param_List::create (cfe_cnt, FALSE); }
  572.       | l_par_tok
  573.     parameters_1
  574.     r_par_tok
  575.     {  $$ = $2; }
  576.      ;
  577.  
  578. parameters_1
  579.       : parameter
  580.         {  $$ = sos_Param_List::create (cfe_cnt, FALSE);
  581.        $$.append ($1);
  582.         }
  583.       | parameters_1
  584.     comma_tok
  585.     parameter
  586.     {  $1.append ($3);
  587.            $$ = $1;
  588.         }
  589.      ;
  590.  
  591. parameter
  592.       : type_name
  593.     reference
  594.     name
  595.     default_expr
  596.     {  $$ = sos_Param::create (cfe_cnt);
  597.        $$.set_name ($3);
  598.        $$.set_type_name ($1);
  599.        $$.set_default_expr ($4);
  600.        $$.set_is_ref ($2);
  601.     }
  602.       | type_name
  603.     reference
  604.     default_expr
  605.     {  $$ = sos_Param::create (cfe_cnt);
  606.        $$.set_name (sos_String::make (NO_OBJECT));
  607.        $$.set_type_name ($1);
  608.        $$.set_default_expr ($3);
  609.        $$.set_is_ref ($2);
  610.     }
  611.      ;
  612.  
  613. reference
  614.       : { $$ = FALSE; }
  615.       | ampersand_tok
  616.         { $$ = TRUE; }
  617.       ;
  618.  
  619.  
  620. default_expr
  621.       : {  $$ = sos_Expr::make (NO_OBJECT); }
  622.       | assign_tok
  623.     expr
  624.     {  $$ = $2; }
  625.      ;
  626.  
  627. comp_methods
  628.       : comp_names
  629.     semicolon_tok
  630.       ;
  631.  
  632. comp_names : comp_name
  633.        | comp_names
  634.          comma_tok
  635.          comp_name
  636.        ;
  637.  
  638. comp_name : name1
  639.         default_expr
  640.         {  if (cfe_method_is_definite)
  641.               cfe_error(err_WNG, err_CFE_NO_DEFINITE_COMPS);
  642.            if (cfe_method_is_static)
  643.               cfe_error(err_USE, err_CFE_NO_STATIC_COMPS);
  644.            if (cfe_method_is_value)
  645.               cfe_error(err_USE, err_CFE_NO_VALUE_COMPS);
  646.               
  647.            cfe_append_comp_methods
  648.           (cfe_ct, cfe_fct_or_comp_type, $1, $2,
  649.            cfe_method_kind, cfe_set_method_kind,
  650.            cfe_method_is_value, cfe_method_is_local,
  651.            cfe_component_offset);
  652.            if ($2 != NO_OBJECT)
  653.           cfe_ct.set_has_init_comps (TRUE);
  654.         }
  655.       ;
  656.  
  657. friend : friend_tok
  658.      class_tok
  659.      type_name1
  660.      semicolon_tok
  661.      {  cfe_ct.get_friends().append ($3);
  662.      }
  663.       ;
  664.  
  665. union_declaration
  666.       : union_tok
  667.         name
  668.         {  cfe_check_type ($2); }
  669.         l_brc_tok
  670.         type_names
  671.         r_brc_tok
  672.     opt_semicolon
  673.     {  $$ = sos_Union_type::create (cfe_cnt);
  674.            $$.set_name ($2);
  675.            $$.set_uniteds ($5);
  676.  
  677.            cfe_type_tab.insert ($2, $$);
  678.            cfe_types.append ($$);
  679.     }
  680.      ;
  681.  
  682. typedef_declaration
  683.     : typedef_tok
  684.           type_name
  685.           name
  686.           {  $$ = sos_Typedef_type::create (cfe_cnt);
  687.              $$.set_name ($3);
  688.          $$.set_type_name ($2);
  689.          if ($2.make_base_type().has_type (sos_Class_type_type))
  690.          {  sos_Class_type ct = sos_Class_type::make ($2.make_base_type());
  691.         cfe_make_class_type ($3, ct);
  692.          }
  693.          else
  694.         cfe_check_type ($3);
  695.  
  696.              cfe_type_tab.insert ($3, $$);
  697.              cfe_types.append ($$);
  698.       }
  699.     ;
  700.  
  701. extern_declaration
  702.     : extern_tok
  703.           name
  704.       extern_size
  705.           {  cfe_check_type ($2);
  706.          $$ = sos_Extern_type::create (cfe_cnt);
  707.          $$.set_name ($2);
  708.          $$.set_object_size ($3);
  709.          cfe_schema.set_has_external_types (TRUE);
  710.  
  711.              cfe_type_tab.insert ($2, $$);
  712.              cfe_types.append ($$);
  713.       }
  714.     ;
  715.  
  716. extern_size : { $$ = 4; }
  717.         | l_par_tok
  718.           number_tok
  719.           r_par_tok
  720.           { $$ = $2;
  721.         if ($2 > SOS_ID_SIZE)
  722.         {  cfe_error (err_USE, err_CFE_INVALID_EXT_SIZE); }
  723.           }
  724.         ;
  725.  
  726. type_name : type_name1
  727.         {  $$ = $1;
  728.            cfe_check_no_generic ($1);
  729.         }
  730.        ;
  731.  
  732. type_name1 : name1
  733.          {  $$ = cfe_lookup_type_name (cfe_ct, $1); }
  734.        | generic_instantiation
  735.          {  $$ = $1; }
  736.       ;
  737.  
  738. exprs : {  $$ = sos_Expr_List::create (cfe_cnt, FALSE); }
  739.       | exprs1
  740.       ;
  741.  
  742. exprs1 : expr
  743.      {  $$ = sos_Expr_List::create (cfe_cnt, FALSE);
  744.         $$.append ($1);
  745.      }
  746.        | exprs1
  747.      comma_tok
  748.      expr
  749.      {  $1.append ($3);
  750.         $$ = $1;
  751.      }
  752.       ;
  753.  
  754. expr : identifier
  755.        {  $$ = $1; }
  756.      | number
  757.        {  $$ = $1; }
  758.     ;
  759.  
  760. identifier : name
  761.          {  $$ = sos_Identifier::create (cfe_cnt);
  762.             $$.set_id($1);
  763.          }
  764.       ;
  765.  
  766. number : number_tok
  767.      {  $$ = sos_Int_expr::create (cfe_cnt);
  768.         $$.set_value($1);
  769.      }
  770.       ;
  771.  
  772. generic_instantiation
  773.       : name1
  774.     l_abr_tok
  775.     type_names
  776.     r_abr_tok
  777.     {  $$ = cfe_lookup_generic_instantiation ($1, $3, cfe_types);
  778.        cfe_gen_insts.append ($$);
  779.     }
  780.      ;
  781.  
  782. type_names
  783.       : type_name
  784.     {  $$ = sos_Type_name_List::create (cfe_cnt, FALSE);
  785.        $$.append ($1);
  786.     }
  787.       | type_names
  788.     comma_tok
  789.     type_name
  790.     {  $1.append ($3);
  791.        $$ = $1;
  792.     }
  793.      ;
  794.  
  795. name1 : name_tok_or_keyword
  796.         {  $$ = smg_String ($1).make_String (TEMP_CONTAINER);
  797.        delete $1;
  798.         }
  799.        ;
  800.  
  801. names : name
  802.     {  $$ = sos_String_List::create (cfe_cnt, FALSE);
  803.        $$.append ($1);
  804.     }
  805.       | names
  806.         comma_tok
  807.         name
  808.     {  $1.append ($3);
  809.        $$ = $1;
  810.     }
  811.      ;
  812.  
  813. name : name_tok_or_keyword
  814.        {  $$ = smg_String ($1).make_String (cfe_cnt);
  815.       delete $1;
  816.        }
  817.       ;
  818.  
  819. name_tok_or_keyword : name_tok
  820.             | set_tok
  821.               {  $$ = strdup ("set"); }
  822.             ;
  823.  
  824. %%
  825.  
  826. void yyerror (err_msg s) {cfe_error (err_USE, s);}
  827.  
  828. void yyecho () {if (cfe_echo_flag) ECHO;}
  829.